using namespace std;

extern struct COLLADA colladafile;
extern string collada_flat;

//------------------- library_geometries ------------------//
struct P
{
	unsigned int m_Count;
	unsigned short *m_Indices;
};


struct Input
{
	char* m_Semantic;
	char* m_Source;
	char* m_Offset;
	char* m_Set;
};


struct Triangles
{
	int number_inputs;
	unsigned int m_Count;
	char* m_Material;
	struct Input *m_Inputs;
	struct P *m_p;
};


struct Vertices
{
	char* m_ID;
	struct Input *m_Inputs;
};


struct Param
{
	char *m_Name;
	char *m_Type;
};


struct Accessor
{
	char *m_Source;
	unsigned int m_Count;
	unsigned int m_Stride;
	struct Param *m_Params;
};


struct Technique_Common
{
	struct Accessor *m_Accessor;
};


struct Float_Array
{
	unsigned int m_Count;
	char *m_ID;
	double *m_Floats;
};


struct Name_Array
{
	unsigned int m_Count;
	char *m_ID;
	char *m_Names;
};


struct Source
{
	char *m_ID;
	struct Float_Array *m_Float_Array;
	struct Name_Array *m_Name_Array;
	struct Technique_Common *m_TechniqueCommon;
};


struct Mesh
{
	int number_triangles;
	int number_sources;
	struct Source *m_Sources;
	struct Vertices *m_Vertices;
	struct Triangles *m_Triangles;
};


struct Geometry
{
	struct Mesh *m_Mesh;
};


struct GeometryLibrary
{
	struct Geometry *m_Geometries;
	int number_geometrices;
};

//------------------- library_visual_scenes ------------------//

struct Skeleton
{
	char *rootNodeID;
};


struct InstanceController
{
	struct Skeleton *m_Skeletons;
};


struct Matrix
{
	float m_TransformationMatrix[16]; 
};


struct Node
{
	struct InstanceController *m_InstanceControllers;
	struct Matrix *m_Matrix;
	struct Node *m_Node;
	char *m_Id;
	char *m_Sid;
};


struct VisualScene
{
	struct Node *m_nodes;
};


struct VisualSceneLibrary
{
	struct VisualScene *m_VisualScenes;
};

//------------------- library_controllers ------------------//

struct VertexWeights
{
	int count;
	struct Input *m_Input;
	int *vcount;
	int *v;
};


struct Skin
{
	float bind_shape_matrix[16];
	struct Source *m_Source;
	struct VertexWeights *m_vertex_weights;
};

struct Controller
{
	struct Skin *m_Skin;	
};


struct ControllerLibrary
{
	struct Controller m_Controller;
};

//------------------- Collada Root ------------------//

struct COLLADA
{
	struct ControllerLibrary *m_ControllerLibrary;
	struct GeometryLibrary *m_GeometryLibrary;
	struct VisualSceneLibrary *m_VisualSceneLibrary;
};

///////////////////////////////////////////////////////

namespace Collada
{
	class MyCollada
	{
		public: 
		
			//load a file into a TinyXML DOM
			static __declspec(dllexport) int ColladaReader(const char* pFilename, struct COLLADA *colladafile);

			//render model
			static __declspec(dllexport) void RenderCollada (const struct COLLADA *colladafile);

			//release memory
			static __declspec(dllexport) void FreeCollada (struct COLLADA *colladafile);
	
	};
}